package  
{
	import org.flixel.*;

	public class PlayState extends FlxState 
	{
		//this stuff will probably be passed into the constructor for each level
		[Embed(source = "../levels/level1_floor.csv", mimeType = "application/octet-stream")] protected var mapFloor:Class;
		[Embed(source = "../levels/level1_obstacles.csv", mimeType = "application/octet-stream")] protected var mapObstacles:Class;
		[Embed(source = "../art/tileMap.png")] protected var gfxTileMap:Class;
		
		private var levelFloor:FlxTilemap = new FlxTilemap();
		private var levelObstacles:FlxTilemap = new FlxTilemap();
		
		private var clumps:FlxGroup;
		
		private var player:Player;
		private var playerBullets:FlxGroup;
		private var bullet:Bullet;
		
		public function PlayState() {
			super();
		}
		
		override public function create():void {
			player = new Player(FlxG.width / 2, FlxG.height / 2)
			
			clumps = new FlxGroup();
			var clump:Clump;
			for (var i:int = 0; i < 0; i++) {  //release will have 200
				clump = new Clump(FlxU.random() * FlxG.width, FlxU.random() * FlxG.height, 2);
				clumps.add(clump);
				add(clump);
			}
			
			playerBullets = new FlxGroup();
			for (i = 0; i < 100; i++) {
				bullet = new Bullet();
				playerBullets.add(bullet);
			}
			player.bullets = playerBullets.members;
			add(playerBullets);
			
			add(levelFloor.loadMap(new mapFloor, gfxTileMap, 16, 16));
			add(levelObstacles.loadMap(new mapObstacles, gfxTileMap, 16, 16));
			
			add(player);
		}
		
		override public function update():void {
			player.collide(levelFloor);
			FlxU.collide(playerBullets, levelFloor);
			
			super.update();
		}
		
	}

}